#include"sharedmem.hpp"

extern Log log;



int main()
{
    Init i;
    int shmid = createSharedMem();
    if(shmid < 0)
    {
        log(Fatal,"process a creat fail!");
        exit(1);
    }
    log(Info,"process a creat sucess !");
    char* address = (char*)shmat(shmid,nullptr,0);

    log.enable(ClassFile);
    //通讯
    int fd = open(FIFO_FILE,O_RDONLY);
    if(fd < 0)
    {
        log(Fatal,"error string: error code:",strerror(errno),errno);
        exit(FILE_OPEN_ERR);
    }

    while(true)
    {
        char c;
        ssize_t n = read(fd,&c,1);
        if(n == 0)
            break;
        std::cout << "processb say@"<< address;
        //sleep(1);
    }
    shmdt(address);
    shmctl(shmid,IPC_RMID,nullptr);

    close(fd);
}